#include<iostream>
using namespace std;
#include<string.h>
int my_strcmp(char* p1, char* p2) {
	int len1 = strlen(p1);
	int len2 = strlen(p2);
	if (len1 > len2) {
		return 1;
	}
	else if (len1 < len2) {
		return -1;
	}
	else {
		int max = 0;
		for (int i = 0; i < len1; i++) {
			if (*(p1 + i) > *(p2 + i)) {
				max++;
			}
		}
		if (max > len1 - max) {
			return 1;
		}
		else if (max < len1 - max) {
			return -1;
		}
		else {
			return 0;
		}
	}
}
int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		char arr1[20];
		char arr2[20];
		cin >> arr1 >> arr2;
		int m = my_strcmp(arr1, arr2);
		cout << m << endl;
	}
	return 0;
}